﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.inventory
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int inid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(inid);
				}
			}
		}
			
	private void ShowInfo(int inid)
	{
		dzs.BLL.inventory bll=new dzs.BLL.inventory();
		dzs.Model.inventory model=bll.GetModel(inid);
		this.lblinid.Text=model.inid.ToString();
		this.txtmid.Text=model.mid.ToString();
		this.txtspid.Text=model.spid.ToString();
		this.txtnums.Text=model.nums.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtmid.Text))
			{
				strErr+="mid格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtspid.Text))
			{
				strErr+="spid格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtnums.Text))
			{
				strErr+="nums格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int inid=int.Parse(this.lblinid.Text);
			int mid=int.Parse(this.txtmid.Text);
			int spid=int.Parse(this.txtspid.Text);
			decimal nums=decimal.Parse(this.txtnums.Text);


			dzs.Model.inventory model=new dzs.Model.inventory();
			model.inid=inid;
			model.mid=mid;
			model.spid=spid;
			model.nums=nums;

			dzs.BLL.inventory bll=new dzs.BLL.inventory();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
